
package com.datawin.taotaocheche.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.datawin.taotaocheche.ui.actviity.user.WebViewLoadAct;
import com.superrecycleview.superlibrary.adapter.BaseViewHolder;
import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter;

import java.util.List;

import com.datawin.taotaocheche.R;
import com.datawin.taotaocheche.bean.MsgInfo;

/**
 * chenjian
 */
public class MsgAdapter extends SuperBaseAdapter<MsgInfo> {

    private Context mContext;

    public MsgAdapter(Context context, List<MsgInfo> data) {
        super(context, data);

        mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder holder, final MsgInfo item, int position) {
        holder.setText(R.id.item_msg_title, item.getContent()).setText(R.id.item_msg_time, item.getCreateTime());
        if (item.getType() == 1) {
            holder.setOnClickListener(R.id.item_layout_msg, new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(mContext, WebViewLoadAct.class);
                    intent.putExtra("htmlStr", item.getHtmlStr());
                    mContext.startActivity(intent);
                }
            });
        }
    }

    @Override
    protected int getItemViewLayoutId(int position, MsgInfo item) {
        return R.layout.item_meg;
    }
}
